package com.czxy.demo24;

import org.apache.commons.beanutils.BeanUtils;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.InvocationTargetException;
import java.util.Properties;

public class Test01 {
    public static void main(String[] args) throws IOException, ClassNotFoundException, IllegalAccessException, InstantiationException, InvocationTargetException {
        InputStream is=new FileInputStream(new File("data.properties"));
        Properties pro=new Properties();
        pro.load(is);
        is.close();
        Class<?>aClass=Class.forName("com.czxy.demo01.User");
        Object o = aClass.newInstance();
        for (Object o1 : pro.keySet()) {
            BeanUtils.setProperty(o,o1+"",pro.get(o1));
        }
        System.out.println(o);
    }
}
